package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: InviteLinkController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-14
 * @Version: 1.0
 * Table: pear_invite_link
 * Comment:
 * 邀请链接表
 */
@RestController
@RequestMapping(value = "/invite_link")
public class InviteLinkController extends InviteLinkCustomController {
    static {
        addRequestClass("invite_link", "add", "inviteLinkController", InviteLinkController.class, InviteLinkAddRequest.class);
        addRequestClass("invite_link", "add_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkAddRequest.class);

        addRequestClass("invite_link", "update", "inviteLinkController", InviteLinkController.class, InviteLinkUpdateRequest.class);
        addRequestClass("invite_link", "update_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkUpdateRequest.class);

        addRequestClass("invite_link", "delete", "inviteLinkController", InviteLinkController.class, InviteLinkDeleteRequest.class);
        addRequestClass("invite_link", "delete_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkDeleteRequest.class);

        addRequestClass("invite_link", "query", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);
        addRequestClass("invite_link", "query_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);

        addRequestClass("invite_link", "list", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);
        addRequestClass("invite_link", "list_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);

        addRequestClass("invite_link", "count", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);
        addRequestClass("invite_link", "count_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);

        addRequestClass("invite_link", "stat", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);
        addRequestClass("invite_link", "stat_encrypt", "inviteLinkController", InviteLinkController.class, InviteLinkQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addInviteLink(@MixRequestBody InviteLinkAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("invite_link", "add", request, callFromEncrypt);
        return super.addInviteLink(request);
    }

    @PostMapping("/add_encrypt")
    public String addInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkAddRequest request = (InviteLinkAddRequest) super.decrypt("invite_link", "add_encrypt", strRequest, InviteLinkAddRequest.class);
        Integer result = addInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateInviteLink(@MixRequestBody InviteLinkUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("invite_link", "update", request, callFromEncrypt);
        return super.updateInviteLink(request);
    }

    @PostMapping("/update_encrypt")
    public String updateInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkUpdateRequest request = (InviteLinkUpdateRequest) super.decrypt("invite_link", "update_encrypt", strRequest, InviteLinkUpdateRequest.class);
        Integer result = updateInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteInviteLink(@MixRequestBody InviteLinkDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("invite_link", "delete", request, callFromEncrypt);
        return super.deleteInviteLink(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkDeleteRequest request = (InviteLinkDeleteRequest) super.decrypt("invite_link", "delete_encrypt", strRequest, InviteLinkDeleteRequest.class);
        Integer result = deleteInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public InviteLinkQueryResponse queryInviteLink(@MixRequestBody InviteLinkQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("invite_link", "query", request, callFromEncrypt);
      return super.queryInviteLink(request);
    }

    @PostMapping("/query_encrypt")
    public String queryInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkQueryRequest request = (InviteLinkQueryRequest) super.decrypt("invite_link", "query_encrypt", strRequest, InviteLinkQueryRequest.class);
        InviteLinkQueryResponse result = queryInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<InviteLinkQueryResponse> listInviteLink(@MixRequestBody InviteLinkQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("invite_link", "list", request, callFromEncrypt);
        if (super.needTotal("invite_link", "list", request)) {
            super.setTotal("invite_link", "list", request, super.countInviteLink(request));
        }
        return super.listInviteLink(request);
    }

    @PostMapping("/list_encrypt")
    public String listInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkQueryRequest request = (InviteLinkQueryRequest) super.decrypt("invite_link", "list_encrypt", strRequest, InviteLinkQueryRequest.class);
        List<InviteLinkQueryResponse> result = listInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countInviteLink(@MixRequestBody InviteLinkQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("invite_link", "count", request, callFromEncrypt);
      return super.countInviteLink(request);
    }


    @PostMapping("/count_encrypt")
    public String countInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkQueryRequest request = (InviteLinkQueryRequest) super.decrypt("invite_link", "count_encrypt", strRequest, InviteLinkQueryRequest.class);
        Integer result = countInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statInviteLink(@MixRequestBody InviteLinkQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("invite_link", "stat", request, callFromEncrypt);
        return super.statInviteLink(request);
    }

    @PostMapping("/stat_encrypt")
    public String statInviteLinkEncrypt(@MixRequestBody String strRequest) throws Exception {
        InviteLinkQueryRequest request = (InviteLinkQueryRequest) super.decrypt("invite_link", "stat_encrypt", strRequest, InviteLinkQueryRequest.class);
        BaseStatResponse result = statInviteLink(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
